<?php

namespace App\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;

//商品分类
/**
 * App\Models\Cate
 *
 * @property int $id 商品类目id
 * @property string $name 类目名
 * @property int $sort 类目显示排序，数字越大越靠前。
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property Carbon|null $deleted_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Cate onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cate whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Cate withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Cate withoutTrashed()
 * @mixin Eloquent
 */
class Cate extends Model
{
    use SoftDeletes;

    //返回所有未软删除的类目
    function get_all_cates($where = []){
        return $this->select('id','name','cover')->where($where)->orderBy('sort','desc')->orderBy('id','desc')->get();
    }
}
